package com.sgcc.pda.sdk.utils.db;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;

import com.sgcc.pda.baselibrary.utils.DeviceUtil;
import com.sgcc.pda.baselibrary.utils.JsonUtil;
//import com.sgcc.pda.greendao.model.SharePreferenceModel;
import com.sgcc.pda.sdk.entity.table.SharepreferenceInfo;
import com.sgcc.pda.sdk.entity.table.UserInfo;
import com.sgcc.pda.sdk.utils.CharacterParser;
import com.sgcc.pda.sdk.utils.NetWorkUtil;

import java.util.ArrayList;
import java.util.List;


/**
 * 系统配置参数数据存储
 *
 * @author:GuangJie-Wang
 * @Date: 2016/4/21
 * @Time: 15:31
 */
public class SharepreferenceUtil {
    /**
     * sp类型：String
     */
    public static final int SP_TYPE_STRING = 0;

    /**
     * sp类型：int
     */
    public static final int SP_TYPE_INT = 1;

    /**
     * sp类型：boolean
     */
    public static final int SP_TYPE_BOOLEAN = 2;

    /**
     * sp类型：float
     */
    public static final int SP_TYPE_FLOAT = 3;

    /**
     * sp类型：long
     */
    public static final int SP_TYPE_LONG = 4;

    /**
     * sp类型：Set<String>
     */
    public static final int SP_TYPE_SET = 5;

    /****************************
     * 是否人脸识别
     ***************************/
    private static final String LOGIN_MODE = "loginMode";
    private static final String IS_FACE_LOGIN = "isFaceLogin";
    /*******************
     * 1.0 2.0判断
     *******************/
    private static final String SAFE_VERSION = "SAFE_VERSION";//安全单元版本
    private static final String SAFE_VERSION_CODE = "SAFE_VERSION_CODE";//安全单元版本号

    /*******************
     * 获取上次安装版本名称
     *******************/
    private static final String BEFORE_VERSION_NAME = "VERSION_NAME";//上次安装版本名称

    /*******************
     * 安全单元加载过程配置
     *******************/
    private static final String SAFE_ORDER_NUM = "SAFE_ORDER_NUM";//安全单元版本
    private static final String SAFE_ODER_CODE = "SAFE_ODER_CODE";//安全单元版本号
    /*******************
     * so版本序号
     *******************/
    private static final String SO_VERSION = "SO_VERSION";
    private static final String SO_VERSION_CODE = "SO_VERSION_CODE";
    // SharedPreferences名称
    /*******************
     * 操作员号和业务员号
     *******************/

    private static final String OPERATE = "operate";
    private static final String OPERATORNO = "operatorNo";//操作员号
    private static final String OPERATORNAME = "operatorName";//操作员号
    private static final String OPERATIONNO = "operationNo";//业务员号
    private static final String DEV_SNNO = "dev_snNo"; //服务终端序列号
    private static final String SIMCARD_SNNO = "simcard_snNo"; //sim卡序列号
    private static final String FAULTNUM = "faultnum"; //消缺达人

    private static final String LOGININFO = "loginInfo";//保存登录所需信息
    private static final String LOGININFO1 = "loginInfo1";//操作者代码
    private static final String COUNTER = "counter";//yesam对称秘钥版本
    private static final String OPERATER = "operater";//操作者代码
    private static final String MSCF = "mscf";//主站证书
    private static final String TCF = "tcf";//终端证书
    private static final String MSCFV = "mscfv";//主站证书版本号
    private static final String MSCFM = "mscfm";//主站证书序列号
    private static final String TCFV = "tcfv";//终端证书版本号
    private static final String TCFM = "tcfm";//终端证书序列号
    private static final String SV = "sv";//安全单元软件版本号
    private static final String HV = "hv";//安全单元硬件版本号
    private static final String SYSV = "sysv";//操作系统版本号

    private static final String DEPT_NAME = "DEPT_NAME";//部门名称
    private static final String DEPT_CODE = "DEPT_CODE";//部门编码
    private static final String ORG_NAME = "ORG_NAME";//机构名称
    private static final String ORG_CODE = "ORG_CODE";//机构编码
    private static final String PER_ORG_CODE = "PER_ORG_CODE";//上级机构编码
    private static final String ORG_TYPE = "ORG_TYPE";//供电单位类别
    private static final String CALLER_PACKAGE_NAME = "CALLER_PACKAGE_NAME";//调用者包名
    private static final String CALLER_USER_CODE = "CALLER_USER_CODE";//调用者账号
    private static final String CALLER_ORG_NO = "CALLER_ORG_NO";//调用者供电单位编码
    private static final String CALLER_SYS_CODE = "CALLER_SYS_CODE";//调用者所属系统编码
    private static final String BUSINESS_PACKAGE_NAME = "BUSINESS_PACKAGE_NAME";//调用者所要打开app的包名
    private static final String BUSINESS_START_ACTIVITY = "BUSINESS_START_ACTIVITY";//调用者所要打开app的启动类名
    private static final String BUSINESS_TYPE = "BUSINESS_TYPE";//调用者所要执行的业务类型

    private static final String OTH_ACCT_ORG = "OTH_ACCT_ORG";//
    private static final String OTH_ACCT_NO = "OTH_ACCT_NO";//
    private static final String OTH_ACCT_DEPT = "OTH_ACCT_DEPT";//
    private static final String ROLE_ID = "ROLE_ID";//角色id
    private static final String SYS_ROLE_ID = "SYS_ROLE_ID";//SYS角色id
    private static final String SYS_ROLE_TYPE = "SYS_ROLE_TYPE";//SYS角色TYPE


    private static final String ESAMNUMINFO = "esamNoInfo";//操作员姓名
    private static final String ESAMVERSION = "esam";//操作员序列号
    private static final String CESAMNUM = "cesamNo";//操作员序列号
    private static final String CESAMVERSION = "cesamVersion";//cesam对称秘钥版本
    private static final String YESAMNUM = "yesamNo";//业务员序列号
    private static final String YESAMVERSION = "yesamVersion";//yesam对称秘钥版本

    private static final String WATER_MARK_INFO = "water_mark_info";//文本水印信息

    /*******************
     * 上传经纬度配置条件
     *******************/
    private static final String POSITION = "position";
    private static final String MAPAUTHKEY = "mapAuthKey";
    private static final String ISOPEN = "isopen";//是否打开
    private static final String COLLRATE = "collrate";//采集频率
    private static final String LOADRATE = "mapAuthKey";//上传频率
    private static final String ZHENGDUAN = "zhengduan";
    private static final String XIUFU = "xiufu";
    private static final String DEV = "DEV";
    private static final String SIMCARD_SN = "simcard_sn";

    /***********************
     * SIM卡测试参数设置
     ***********************/
    private static final String THINTA = "thinta";
    private static final String COMMUNICATION_IP = "communication_ip";
    private static final String COMMUNICATION_PORT = "communication_port";
    private static final String COMMUNICATION_APN = "communication_apn";

    /**********************
     * 通讯参数设置
     **********************/
    private static final String THINTA_COMM = "thinta_comm";
    private static final String COMM_USBEnable = "comm_usbenable";
    private static final String COMM_IP = "comm_ip";//IP地址
    private static final String COMM_PORT = "comm_port";//端口号
    private static final String COMM_IP_USB = "comm_ip_usb";//USB通信方式IP地址
    private static final String COMM_PORT_USB = "comm_port_usb";//USB通信方式端口号
    private static final String COMM_APNNAME = "comm_apnname";//APN名称
    private static final String COMM_APN = "comm_apn";//APN
    private static final String COMM_USER_NAME = "comm_user_name"; //APN用户名
    private static final String COMM_USER_PSWD = "comm_user_pswd"; //APN密码
    private static final String COMM_SAFE_PSWD = "COMM_SAFE_PSWD"; //安全单元密码
    private static final String COMM_LOGIN_PSWD = "COMM_LOGIN_PSWD"; //登录密码

    private static final String DATA = "data"; //data定义
    private static final String IM = "im_user_id_flag";
    private static final String IM_USER_ID = "im_user_id";

    private static final String USERCODE = "usercode";
    private static final String USERFLAG = "userflag";
    private static final String USERID = "userid";
    private static final String USER_CODE = "usercode";
    private static final String USER_CODE_BH = "USER_CODE_BH";//闭环的code
    private static final String USER_NAME_ = "USER_NAME_";
    private static final String USER_ID_ = "USER_ID_";//刘畅-装拆用的userId

    private static final String MAINFLAG = "mainflag";
    private static final String MAIN = "main";

    private static final String LOGINFLAG = "loginflag";
    private static final String LOGIN_FLAG = "login_flag";

    private static final String LOGIN_ = "LOGIN_";
    private static final String LOGIN_M1 = "LOGIN_M1";
    private static final String LOGIN_UID = "LOGIN_UID";
    private static final String LOGIN_MAC = "LOGIN_MAC";

    //掌机使用人
    private static final String PERSON_ = "PERSON_";
    private static final String PERSON_PARM = "PERSON_PARM";

    private static final String KNOWLEDGE = "knowledge";//知识库版本保存
    private static final String NVK = "nvk";//知识库版本号

    // 是否提醒用户启动微应用APP还是统一版APP
    private static final String APP_BOOT = "APP_BOOT";
    private static final String KEY_SUBMIT = "SUBMIT";

    private static final String AUTHENTICATION = "authentication"; //消缺达人
    public static final String METER_KEY = "meter_pwd";//电能表采集中单密码
    public static final String METER_DEFAULT = "000000";//电能表采集中单密码
    private static final String COMM_SAFE_DECIPHERING_PSWD = "COMM_SAFE_DECIPHERING_PSWD"; //解密安全单元密码
    private static final String COMM_SAFE_DECIPHERING_USB = "COMM_SAFE_DECIPHERING_USB"; //解密安全单元密码开关
    private static final String COMM_WORK_NUM = "COMM_WORK_NUM"; //解密安全单元密码开关

    /*******************
     * MIP网省配置
     *******************/
    private static final String MIP_SETTING = "MIP_SETTING";// MIP配置
    private static final String MIP_PROVINCE = "MIP_PROVINCE";// 网省
    private static final String MIP_APP_ID = "MIP_APP_ID";// APP ID
    private static final String MIP_APP_SECRET = "MIP_APP_SECRET"; // APP SECRET
    private static final String MIP_APP_CODE = "MIP_APP_CODE";// APP CODE
    private static final String MIP_ONLINE_IP = "MIP_ONLINE_IP";// 在线IP
    private static final String MIP_ONLINE_PORT = "MIP_ONLINE_PORT";// 在线端口
    private static final String MIP_LOCAL_IP = "MIP_LOCAL_IP";// 无网络时IP
    private static final String MIP_LOCAL_PORT = "MIP_ONLINE_PORT";// 无网络时端口
    private static final String MIP_LOGIN_ENABLE = "MIP_LOGIN_ENABLE";// 是否显示MIP登录
    private static final String MIP_CUSTOM_SWITCH = "MIP_CUSTOM_SWITCH";// 自定义地址开关

    private static final String COMM_PARAM = "COMM_PARAM";// 系统通用参数
    private static final String COMM_PARAM_DATA = "COMM_PARAM_DATA";// 系统通用参数数据保存
    /**
     * 存储日志天数，提供业务app调用
     */
    private static final String LOG_SAVE_DAYS = "log_save_days";
    /**
     * 绑定校验信息
     */
    private static final String BIND_CHECK_INFO = "BIND_CHECK_INFO";
    /**
     * 绑定业务账号信息
     */
    private static final String BIND_NUMBER_INFO = "BIND_NUMBER_INFO";
    /**
     * 设置电表通讯方式
     */
    private static final String METER_COMM_SETTING = "mode";// editor key
    private static final String METER_COMM_MODE = "mode";// 电表通讯方式
    private static final String METER_485_BAUD = "mode_485_baud";// 485波特率
    private static final String METER_485_DATA_BIT = "mode_485_data_bit";// 485数据位
    private static final String METER_485_CHECK_BIT = "mode_485_check_bit";// 485校验位
    private static final String METER_485_STOP_BIT = "mode_485_stop_bit";// 485停止位
    /**
     * 是否进行账号绑定校验（mds）
     */
    private static final String IS_BINDING_CHECK_KEY = "IS_BINDING_CHECK_KEY";// 是否进行账号绑定校验配置

    private static final String ONE_KEY_PACKAGE_STATE = "ONE_KEY_PACKAGE_STATE";// 一键执行功能码：0：关闭； 1：开启

    /**
     * 设置工单自动上传时间
     */
    private static final String ORDER_UPLOAD_TIME = "ORDER_UPLOAD_TIME";
    /**
     * 设置app下载分块大小
     */
    private static final String APP_DOWNLOAD_SIZE = "APP_DOWNLOAD_SIZE";
    /**
     * 设置文件分块上传大小
     */
    private static final String FLIE_UPLOAD_SIZE = "FLIE_UPLOAD_SIZE";
    // 允许文件上传类型
    private static final String WF_FILE_UPLOAD_TYPE = "WF_FILE_UPLOAD_TYPE";
    // 允许文件上传大小
    private static final String WF_FILE_UPLOAD_SIZE = "WF_FILE_UPLOAD_SIZE";
    // APP参数更新版本号
    private static final String APP_PARAM_UPDATE_VERSION = "APP_PARAM_UPDATE_VERSION";
    // app版本号保存
    private static final String APP_VERSION_CODE = "APP_VERSION_CODE";
    // 用户人员职责信息
    private static final String OPER_DUTY = "OPER_DUTY";

    // 首页Banner图
    private static final String BANNER_IMG = "BANNER_IMG";
    /**
     * 初始密码
     */
    private static final String ORIGION_KEY = "ORIGION_PWD";
    /**
     * 密码规则
     */
    private static final String KEY_REGEX = "PWD_REGEX";

    /**
     * 是否开启加密模式
     */
    private static final String ENCRYPTIONMODE = "encryptionmode";
    private static final String ENCRYPTION_MODE = "encryption_mode";

    /*TODO
    private static SharePreferenceModel model;

    private static SharePreferenceModel getModel(){
        if(model == null){
            model = new SharePreferenceModel();
        }
        return model;
    }*/

    /**
     * 用户已选择，不再提醒启动微应用APP还是统一版APP
     *
     * @param context
     */
    public static void setAppBootSubmit(Context context) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(APP_BOOT);
        info.setEditorMode(0);
        info.setKey(KEY_SUBMIT);
        info.setValue("1");
        info.setType(SP_TYPE_BOOLEAN);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 是否提醒用户启动微应用APP还是统一版APP，true不提醒，false提醒
     *
     * @param context
     * @return
     */
    public static boolean getAppBootSubmit(Context context) {
        return ContentProviderUtil.getSharepreferenceBooleanValue(context, APP_BOOT, KEY_SUBMIT);
    }


    /**
     * 获取操作者代码
     *
     * @param context
     * @return
     */
    public static String getOperator(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO1, OPERATER);
    }

    public static void setOperator(Context context, String softVersion) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO1);
        info.setEditorMode(0);
        info.setKey(OPERATER);
        info.setValue(softVersion);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    public static void setSoftVersion(Context context, String softVersion) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(SV);
        info.setValue(softVersion);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 安全单元软件版本号
     *
     * @param context
     * @return
     */
    public static String getSoftVersion(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, SV);
    }


    /**
     * 设置单位名称
     *
     * @param context
     * @param deptName
     */
    public static void setDeptName(Context context, String deptName) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(DEPT_NAME);
        info.setValue(deptName);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取单位名称
     *
     * @param context
     * @return
     */
    public static String getDeptName(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, DEPT_NAME);
    }

    /**
     * 设置单位编码
     *
     * @param context
     * @param deptCode
     */
    public static void setDeptCode(Context context, String deptCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(DEPT_CODE);
        info.setValue(deptCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取单位编码
     *
     * @param context
     * @return
     */
    public static String getDeptCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, DEPT_CODE);
    }


    /**
     * 设置机构名称
     *
     * @param context
     * @param orgName
     */
    public static void setOrgName(Context context, String orgName) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(ORG_NAME);
        info.setValue(orgName);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取机构名称
     *
     * @param context
     * @return
     */
    public static String getOrgName(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, ORG_NAME);
    }

    /**
     * 设置机构编码
     *
     * @param context
     * @param orgCode
     */
    public static void setOrgCode(Context context, String orgCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(ORG_CODE);
        info.setValue(orgCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取机构编码
     *
     * @param context
     * @return
     */
    public static String getOrgCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, ORG_CODE);
    }

    /**
     * 对端系统供电单位
     *
     * @param context
     * @param orgCode
     */
    public static void setOthAcctOrg(Context context, String orgCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(OTH_ACCT_ORG);
        info.setValue(orgCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    public static String getOthAcctOrg(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, OTH_ACCT_ORG);
    }

    /**
     * 对端系统账号
     *
     * @param context
     * @param orgCode
     */
    public static void setOthAcctNo(Context context, String orgCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(OTH_ACCT_NO);
        info.setValue(orgCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    public static String getOthAcctNo(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, OTH_ACCT_NO);
    }

    /**
     * 对端系统部门id 【业务自己账号的部门id】
     *
     * @param context
     * @param orgCode
     */
    public static void setOthAcctDept(Context context, String orgCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(OTH_ACCT_DEPT);
        info.setValue(orgCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    public static String getOthAcctDept(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, OTH_ACCT_DEPT);
    }


    /**
     * 设置角色id
     *
     * @param context
     * @param orgCode
     */
    public static void setRoleId(Context context, String orgCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(ROLE_ID);
        info.setValue(orgCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 获取角色id
     *
     * @param context
     * @return
     */
    public static String getRoleId(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, ROLE_ID);
    }


    /**
     * 安全单元硬件版本号
     *
     * @param context
     * @return
     */
    public static String getHardVersion(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, HV);
    }

    public static void setHardVersion(Context context, String hardVersion) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(HV);
        info.setValue(hardVersion);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 操作系统版本号
     *
     * @param context
     * @return
     */
    public static String getSystemVersion(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, SYSV);
    }

    public static void setSystemVersion(Context context, String systemVertion) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(SYSV);
        info.setValue(systemVertion);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * Y-EESAM密钥版本
     *
     * @param context
     * @return
     */
    public static String getYEsamVersion(Context context) {
        String sharepreferenceValue = ContentProviderUtil.getSharepreferenceValue(context, ESAMVERSION, YESAMVERSION);
        return TextUtils.isEmpty(sharepreferenceValue) ? "" : sharepreferenceValue;
    }

    public static void setYEsamVersion(Context context, String yesamVersion) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(ESAMVERSION);
        info.setEditorMode(0);
        info.setKey(YESAMVERSION);
        info.setValue(yesamVersion);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 会话计数器
     *
     * @param context
     * @return
     */
    public static String getCounter(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, COUNTER);
    }

    public static void setCounter(Context context, String counter) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(COUNTER);
        info.setValue(counter);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * C-EESAM密钥版本
     *
     * @param context
     * @return
     */
    public static String getCEsamVersion(Context context) {
        String sharepreferenceValue = ContentProviderUtil.getSharepreferenceValue(context, ESAMVERSION, CESAMVERSION);
        return TextUtils.isEmpty(sharepreferenceValue) ? "" : sharepreferenceValue;
    }

    public static void setCEsamVersion(Context context, String cesamVersion) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(ESAMVERSION);
        info.setEditorMode(0);
        info.setKey(CESAMVERSION);
        info.setValue(cesamVersion);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    public static void setMainStationCertificate(Context context, String mscf) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(MSCF);
        info.setValue(mscf);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 主站证书
     *
     * @param context
     * @return
     */
    public static String getMainStationCertificate(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, MSCF);
    }


    public static void setMainStationCertificateVersion(Context context, String mscfv) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(MSCFV);
        info.setValue(mscfv);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 主站证书版本号
     *
     * @param context
     * @return
     */
    public static String getMainStationCertificateVersion(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, MSCFV);
    }


    /**
     * 主站证书序列号
     *
     * @param context
     * @return
     */
    public static String getMainStationCertificateNum(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, MSCFM);
    }

    public static void setMainStationCertificateNum(Context context, String mscfm) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(MSCFM);
        info.setValue(mscfm);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 终端证书版本号
     *
     * @param context
     * @return
     */
    public static String getTerminalCertificateVersion(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, TCFV);
    }

    public static void setTerminalCertificateVersion(Context context, String tcfv) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(TCFV);
        info.setValue(tcfv);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    public static void setTerminalCertificateNum(Context context, String tcfm) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(TCFM);
        info.setValue(tcfm);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 终端证书序列号
     *
     * @param context
     * @return
     */
    public static String getTerminalCertificateNum(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, TCFM);
    }

    /**
     * 终端证书
     *
     * @param context
     * @return
     */
    public static String getTerminalCertificate(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, TCF);
    }

    public static void setTerminalCertificate(Context context, String tcf) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(TCF);
        info.setValue(tcf);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * C-EESAM序列号
     *
     * @param context
     * @return
     */
    public static String getCEsamNum(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, ESAMNUMINFO, CESAMNUM);
    }

    public static void setCEsamNum(Context context, String operatorNo) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(ESAMNUMINFO);
        info.setEditorMode(0);
        info.setKey(CESAMNUM);
        info.setValue(operatorNo);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * Y-EESAM序列号
     *
     * @param context
     * @return
     */
    public static String getYEsamNum(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, ESAMNUMINFO, YESAMNUM);
    }

    public static void setYEsamNum(Context context, String operationNo) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(ESAMNUMINFO);
        info.setEditorMode(0);
        info.setKey(YESAMNUM);
        info.setValue(operationNo);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 知识库版本号获取
     *
     * @param context 上下文
     * @return 知识库版本号
     */
    public static String getKnowledgeNVK(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, KNOWLEDGE, NVK);
    }


    public static String getVersion(Context context) {
        ApplicationInfo appInfo = null;
        try {
            appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            if (null != appInfo) {
                return appInfo.metaData.getString("appVrsionCode");
            } else {
                return "00.00.00.00";
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return "00.00.00.00";
        }

    }


    /**
     * 设置usb连接
     *
     * @param context
     * @param usbenable
     */
    public static void setCommUsbEnable(Context context, boolean usbenable) {

        String v;
        if (usbenable) {
            v = "1";
        } else {
            v = "0";
        }

        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(THINTA_COMM);
        info.setEditorMode(0);
        info.setKey(COMM_USBEnable);
        info.setValue(v);
        info.setType(SP_TYPE_BOOLEAN);

        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 设置安全单元版本号
     *
     * @param context
     * @param version 1安全单元1.0  2安全单元2.0
     */
    public static void setSafeVersioin(Context context, int version) {
//        private static final String PDA_VERSION = "PDA_VERSION";//掌机版本
//        private static final String PDA_VERSION_CODE = "PDA_VERSION_CODE";//掌机版本号
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(SAFE_VERSION);
        info.setEditorMode(0);
        info.setKey(SAFE_VERSION_CODE);
        info.setValue(version + "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 设置安全单元加载顺序
     *
     * @param context
     * @param number  安全单元加载顺序
     *                1：加载过程为app_lib
     *                2:system/lib/libcepri_dev
     *                3：system/lib/libcepri
     *                4:armeabi-v7a
     */
    public static void setSafeInitOrder(Context context, int number) {
//        private static final String PDA_VERSION = "PDA_VERSION";//掌机版本
//        private static final String PDA_VERSION_CODE = "PDA_VERSION_CODE";//掌机版本号
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(SAFE_ORDER_NUM);
        info.setEditorMode(0);
        info.setKey(SAFE_ODER_CODE);
        info.setValue(number + "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 获取安全单元加载顺序
     * <p>
     * 1：加载过程为app_lib
     * 2:system/lib/libcepri_dev
     * 3：system/lib/libcepri
     * 4:armeabi-v7a
     */
    public static int getSafeOrderNum(Context context) {
//        private static final String PDA_VERSION = "PDA_VERSION";//掌机版本
//        private static final String PDA_VERSION_CODE = "PDA_VERSION_CODE";//掌机版本号
        if (!TextUtils.isEmpty(ContentProviderUtil
                .getSharepreferenceValue(context, SAFE_ORDER_NUM, SAFE_ODER_CODE))) {
            return Integer
                    .parseInt(ContentProviderUtil
                            .getSharepreferenceValue(context, SAFE_ORDER_NUM, SAFE_ODER_CODE));
        } else {
            return 3;
        }
    }

    /**
     * 获取安全单元版本
     *
     * @param context
     * @return 0未设置  1安全单元1.0  2安全单元2.0
     */
    public static int getSafeVersion(Context context) {

        if (!TextUtils.isEmpty(ContentProviderUtil.getSharepreferenceValue(context, SAFE_VERSION, SAFE_VERSION_CODE))) {
            return Integer.parseInt(ContentProviderUtil.getSharepreferenceValue(context, SAFE_VERSION, SAFE_VERSION_CODE));
        } else {
            return 0;
        }
    }


    /**
     * 设置安全单元密码
     *
     * @param context
     * @param pwd
     * @return
     */
    public static void setCommSafePswd(Context context, String pwd) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(THINTA_COMM);
        info.setEditorMode(0);
        info.setKey(COMM_SAFE_PSWD);
        info.setValue(pwd);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);

    }

    /**
     * 获取安全单元密码
     *
     * @param context
     * @return
     */
    public static String getCommSafePswd(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, COMM_SAFE_PSWD);
    }


    /**
     * 设置登录密码
     *
     * @param context
     * @param pwd
     * @return
     */
    public static void setCommLoginPswd(Context context, String pwd) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(THINTA_COMM);
        info.setEditorMode(0);
        info.setKey(COMM_LOGIN_PSWD);
        info.setValue(pwd);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);

    }

    /**
     * 设置电能表密码
     *
     * @param context
     * @param pwd
     */
    public static void setMeterPwd(Context context, String pwd) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(THINTA_COMM);
        info.setEditorMode(0);
        info.setKey(METER_KEY);
        info.setValue(pwd);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取电能表密码
     *
     * @param context
     */
    public static String getMeterPwd(Context context) {
        String pwd = ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, METER_KEY);
        return TextUtils.isEmpty(pwd) ? METER_DEFAULT : pwd;
    }

    /**
     * 获取登录密码
     *
     * @param context
     * @return
     */
    public static String getCommLoginPswd(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, COMM_LOGIN_PSWD);
    }

    /**
     * 设置uid
     *
     * @param context
     * @param uid
     */
    public static void setUid(Context context, String uid) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGIN_);
        info.setEditorMode(0);
        info.setKey(LOGIN_UID);
        info.setValue(uid);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取uid
     *
     * @param context
     * @return
     */
    public static String getUid(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGIN_, LOGIN_UID);
    }

    /**
     * 保存MAC
     *
     * @param context
     * @param mac
     */
    public static void setMac(Context context, String mac) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGIN_);
        info.setEditorMode(0);
        info.setKey(LOGIN_MAC);
        info.setValue(mac);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取MAC
     *
     * @param context 上下文
     * @return mac值
     */
    public static String getMac(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGIN_, LOGIN_MAC);
    }


    /**
     * 设置掌机操作人员
     *
     * @param context
     * @param response
     */
    public static void setPerson(Context context, String response) {
        SharepreferenceInfo sharepreferenceInfo = new SharepreferenceInfo();
        sharepreferenceInfo.setEditorKey(PERSON_);
        sharepreferenceInfo.setEditorMode(0);
        sharepreferenceInfo.setKey(PERSON_PARM);
        sharepreferenceInfo.setValue(response);
        sharepreferenceInfo.setType(0);
        ContentProviderUtil.setSharepreference(context, sharepreferenceInfo);
    }

    /**
     * 获取掌机操作人
     *
     * @param context
     * @return
     */
    public static List<UserInfo.User> getPerson(Context context) {
        String response = ContentProviderUtil.getSharepreferenceValue(context, PERSON_, PERSON_PARM);
//        String response = USER_TEST_DATA;

        if (TextUtils.isEmpty(response)) {
            return null;
        }
        UserInfo info = JsonUtil.parse(response, UserInfo.class);

        removeDeclard(info.getUSERS());

        if (!TextUtils.isEmpty(info.getRT_F()) && info.getRT_F().equals("1")) {
            List<UserInfo.User> list = new ArrayList<>();
            List<UserInfo.User> users = info.getUSERS();

            if (users == null) return null;
            for (UserInfo.User u : users) {
                u.setUSER_PINYIN(CharacterParser.getInstance().getSelling(u.getUSER_NAME()));
                list.add(u);
            }
            return list;
        } else {
            return null;
        }
    }

    /**
     * 集合中根据对象user_code属性去重
     */
    public static void removeDeclard(List<UserInfo.User> list) {
        if (list == null || list.size() < 2) {
            return;
        }
        for (int i = 0; i < list.size() - 1; i++) {
            UserInfo.User iUser = list.get(i);
            if (iUser == null) {
                continue;
            }
            String iUserCode = iUser.getUSER_CODE();

            for (int j = list.size() - 1; j > i; j--) {
                UserInfo.User jUser = list.get(j);
                if (jUser == null) {
                    continue;
                }
                String jUserCode = jUser.getUSER_CODE();
                if (TextUtils.equals(jUserCode, iUserCode)) {
                    list.remove(j);
                }
            }
        }
    }

    /**
     * 设置登录人id
     */
    public static void setUserID(Context context, String id) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(USERFLAG);
        info.setEditorMode(0);
        info.setKey(USERID);
        info.setValue(id);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 获取登录人Id
     */
    @Deprecated
    public static String getUserID(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, USERFLAG, USERID);
    }


    /**
     * 保存即时通讯 密码
     *
     * @param context
     * @param
     */
    public static void setIMUserID(Context context, String pswd) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey("im_user_id_flag");
        info.setEditorMode(0);
        info.setKey("im_user_id");
        info.setValue(pswd);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 获取即时通信 密码
     *
     * @param context
     * @return
     */
    public static String getIMUserID(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, "im_user_id_flag", "im_user_id");

    }

    /**
     * 知识库版本号保存
     *
     * @param context 上下文
     * @param nvk     版本号
     */
    public static void setKnowledgeNVK(Context context, String nvk) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(KNOWLEDGE);
        info.setEditorMode(0);
        info.setKey(NVK);
        info.setValue(nvk);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 设置M1
     *
     * @param context
     * @param m1
     */
    public static void setM1(Context context, String m1) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGIN_);
        info.setEditorMode(0);
        info.setKey(LOGIN_M1);
        info.setValue(m1);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取M1
     *
     * @param context
     * @return
     */
    public static String getM1(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGIN_, LOGIN_M1);
    }

    /**
     * 设置用户名
     *
     * @param context
     * @param userName
     */
    public static void setOperatorName(Context context, String userName) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(OPERATE);
        info.setEditorMode(0);
        info.setKey(OPERATORNAME);
        info.setValue(userName);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取安全单元用户名
     *
     * @param context
     * @return
     */
    public static String getOperatorName(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, OPERATE, OPERATORNAME);
    }

    /**
     * 设置USER_ID 刘畅-装拆专用
     *
     * @param context
     * @param userName
     */
    public static void setUserID_(Context context, String userName) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(OPERATE);
        info.setEditorMode(0);
        info.setKey(USER_ID_);
        info.setValue(userName);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 获取USER_ID 刘畅-装拆专用
     *
     * @param context
     * @return
     */
    public static String getUserID_(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, OPERATE, USER_ID_);
    }


    /**
     * 设置掌机使用人姓名
     *
     * @param context
     * @param userName
     */
    public static void setUserName(Context context, String userName) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(OPERATE);
        info.setEditorMode(0);
        info.setKey(USER_NAME_);
        info.setValue(userName);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取掌机使用人姓名
     *
     * @param context
     * @return
     */
    public static String getUserName(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, OPERATE, USER_NAME_);
    }

    /**
     * 获取安全单元密码
     *
     * @param context
     * @return
     */
    public static String getSafeUnitPwd(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, COMM_SAFE_DECIPHERING_PSWD);
    }

    /**
     * 获取安全单元密码
     *
     * @param context
     * @return
     */
    public static boolean getCommSafeDecipheringUsb(Context context) {
        String isStartSafeUsb = ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, COMM_SAFE_DECIPHERING_USB);
        return Boolean.parseBoolean(isStartSafeUsb);
    }

    /**
     * 设置安全单元解锁开关
     *
     * @param context
     * @param isSetSafeUsb
     */
    public static void setCommSafeDecipheringUsb(Context context, boolean isSetSafeUsb) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(THINTA_COMM);
        info.setEditorMode(0);
        info.setKey(COMM_SAFE_DECIPHERING_USB);
        info.setValue(isSetSafeUsb + "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);

    }


    /**
     * 设置安全单元解锁密码
     *
     * @param context
     * @param pwd
     */
    public static void setCommSafeUnitPwd(Context context, String pwd) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(THINTA_COMM);
        info.setEditorMode(0);
        info.setKey(COMM_SAFE_DECIPHERING_PSWD);
        info.setValue(pwd + "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 设置登录人账号
     */
    public static void setUserCode(Context context, String user_code) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(USERCODE);
        info.setEditorMode(0);
        info.setKey(USER_CODE);
        info.setValue(user_code);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取登录人账号
     */
   /* public static String getUserCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context,USERCODE,USER_CODE).toUpperCase();
    }*/

    /**
     * 获取登录人账号
     */
    public static String getUserCode(Context context) {
        String userCode = ContentProviderUtil.getSharepreferenceValue(context, USERCODE, USER_CODE);

        return TextUtils.isEmpty(userCode) ? userCode : userCode.toUpperCase();
    }

    /**
     * 设置闭环的code
     */
    public static void setBHUserCode(Context context, String user_code) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(USERCODE);
        info.setEditorMode(0);
        info.setKey(USER_CODE_BH);
        info.setValue(user_code);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取闭环的code
     */
    public static String getBHUserCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, USERCODE, USER_CODE_BH);
    }

    /**
     * 设置操作员编号
     *
     * @param context
     * @param operatorNo
     */
    public static void setOperatorno(Context context, String operatorNo) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(OPERATE);
        info.setEditorMode(0);
        info.setKey(OPERATORNO);
        info.setValue(operatorNo);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 设置业务员编号
     *
     * @param context
     * @param operationNo
     */
    public static void setOperationno(Context context, String operationNo) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(OPERATE);
        info.setEditorMode(0);
        info.setKey(OPERATIONNO);
        info.setValue(operationNo);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);

    }


    /**
     * 设置设备编号
     *
     * @param context
     * @param operationNo
     */
    public static void setDevsnno(Context context, String operationNo) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(DEV);
        info.setEditorMode(0);
        info.setKey(DEV_SNNO);
        info.setValue(operationNo);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 服务终端序列号
     *
     * @param context
     * @return
     */
    public static String getDevsnno(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, DEV, DEV_SNNO);
    }


    /**
     * 获取usb连接状态
     *
     * @param context
     * @return
     */
    public static boolean getCommUsbEnable(Context context) {
        return ContentProviderUtil.getSharepreferenceBooleanValue(context, THINTA_COMM, COMM_USBEnable);
    }


    /**
     * 获取通用usb连接ip
     *
     * @param context
     * @return
     */
    public static String getCommIpUSB(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, COMM_IP_USB);
    }

    /**
     * 获取通用usb连接端口
     *
     * @param context
     * @return
     */
    public static String getCommPortUSB(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, COMM_PORT_USB);
    }

    /**
     * 获取通用设置ip
     *
     * @param context
     * @return
     */
    public static String getCommIp(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, COMM_IP);
    }


    /**
     * 获取通用设置端口
     *
     * @param context
     * @return
     */
    public static String getCommPort(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, THINTA_COMM, COMM_PORT);
    }


    /**
     * 写入sim卡号
     *
     * @param context
     * @param simcard_snNo
     */
    public static void setSimCardSn(Context context, String simcard_snNo) {

        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(SIMCARD_SN);
        info.setEditorMode(0);
        info.setKey(SIMCARD_SNNO);
        info.setValue(simcard_snNo);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 获取通用设置端口
     *
     * @param context
     * @return
     */
    public static String getSimCardSn(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, SIMCARD_SN, "MIRROR_TEST");
    }


    /**
     * 设置登录方式 0  无需登录人  1 需要登录人
     */
    public static void setLoginFlag(Context context, String loginFlag) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGINFLAG);
        info.setEditorMode(0);
        info.setKey(LOGIN_FLAG);
        info.setValue(loginFlag);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);

    }


    /**
     * 操作员号
     *
     * @param context
     * @return
     */
    public static String getOperatorno(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, OPERATE, OPERATORNO);
    }


    /**
     * 业务员号
     *
     * @param context
     * @return
     */
    public static String getOperationno(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, OPERATE, OPERATIONNO);
    }

    /**
     * 保存地图鉴权key
     *
     * @param context
     * @param key
     */
    public static void setMapAuthKey(Context context, String key) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(POSITION);
        info.setEditorMode(0);
        info.setKey(MAPAUTHKEY);
        info.setValue(key);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取保存地图鉴权key
     *
     * @param context
     * @return
     */
    public static String getMapAuthKey(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, POSITION, MAPAUTHKEY);
    }

    /**
     * 设置是否打开定位服务
     *
     * @param context
     * @param is
     */
    public static void setIsopen(Context context, String is) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(POSITION);
        info.setEditorMode(0);
        info.setKey(ISOPEN);
        info.setValue(is);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取是否打开地图服务
     *
     * @param context
     * @return
     */
    public static String getIsopen(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, POSITION, ISOPEN);
    }

    /**
     * 设置采集频率
     *
     * @param context
     * @param is
     */
    public static void setCOLLRATE(Context context, String is) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(POSITION);
        info.setEditorMode(0);
        info.setKey(COLLRATE);
        info.setValue(is);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 设置上传频率
     *
     * @param context
     * @param is
     */
    public static void setLOADRATE(Context context, String is) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(POSITION);
        info.setEditorMode(0);
        info.setKey(LOADRATE);
        info.setValue(is);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 保存即时通讯 ip
     *
     * @param context
     * @param
     */
    public static void setIMIP(Context context, String pswd) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey("im_ip_flag");
        info.setEditorMode(0);
        info.setKey("im_ip");
        info.setValue(pswd);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 保存即时通讯 port
     *
     * @param context
     * @param
     */
    public static void setIMPort(Context context, String pswd) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey("im_ip_flag");
        info.setEditorMode(0);
        info.setKey("im_port");
        info.setValue(pswd);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);

    }

    /**
     * 获取采集频率
     *
     * @param context
     * @return
     */
    public static String getCOLLRATE(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, POSITION, COLLRATE);
    }


    /**
     * 获取上传频率
     *
     * @param context
     * @return
     */
    public static String getLOADRATE(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, POSITION, LOADRATE);
    }

    /**
     * 获取地图鉴权
     *
     * @param context
     * @return
     */
    public static String getauthentication(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, AUTHENTICATION, AUTHENTICATION);
    }

    /**
     * 保存地图鉴权
     *
     * @param context
     */
    public static void saveauthentication(Context context, String str) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(AUTHENTICATION);
        info.setEditorMode(0);
        info.setKey(AUTHENTICATION);
        info.setValue(str);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }


    /**
     * 将工单统计数据存到本地
     *
     * @param context
     */
    public static void setWorkNumData(Context context, String str) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_WORK_NUM);
        info.setEditorMode(0);
        info.setKey(COMM_WORK_NUM);
        info.setValue(str);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 取出本地存入的工单统计数据
     *
     * @param context
     */
    public static String getWorkNumData(Context context) {
        String sharepreferenceValue = ContentProviderUtil.getSharepreferenceValue(context, COMM_WORK_NUM, COMM_WORK_NUM);
        return sharepreferenceValue == null ? "" : sharepreferenceValue;

    }


    /**
     * 设置MIP网省名称
     *
     * @param province 网省名称
     */
    public static void setMipProvince(Context context, String province) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_PROVINCE);
        info.setValue(province);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取MIP配置网省
     *
     * @return province
     */
    public static String getMipProvince(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_PROVINCE);
    }

    /**
     * MIP配置的 APP ID
     *
     * @param appId app id
     */
    public static void setMipAppId(Context context, String appId) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_APP_ID);
        info.setValue(appId);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * MIP配置的APP ID
     *
     * @return app id
     */
    public static String getMipAppId(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_APP_ID);
    }

    /**
     * MIP配置的 APP Secret
     *
     * @param appSecret app Secret
     */
    public static void setMipAppSecret(Context context, String appSecret) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_APP_SECRET);
        info.setValue(appSecret);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * MIP配置的APP Secret
     *
     * @return app Secret
     */
    public static String getMipAppSecret(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_APP_SECRET);
    }

    /**
     * MIP配置的 app Code
     *
     * @param appCode app Code
     */
    public static void setMipAppCode(Context context, String appCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_APP_CODE);
        info.setValue(appCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * MIP配置的 app Code
     *
     * @return app Code
     */
    public static String getMipAppCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_APP_CODE);
    }

    /**
     * 设置MIP在线服务IP
     *
     * @param ip IP
     */
    public static void setMipOnlineIp(Context context, String ip) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_ONLINE_IP);
        info.setValue(ip);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * MIP在线服务IP
     *
     * @return IP
     */
    public static String getMipOnlineIp(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_ONLINE_IP);
    }

    /**
     * 设置MIP在线服务端口
     *
     * @param port port
     */
    public static void setMipOnlinePort(Context context, String port) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_ONLINE_PORT);
        info.setValue(port);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * MIP在线服务端口
     *
     * @return port
     */
    public static String getMipOnlinePort(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_ONLINE_PORT);
    }

    /**
     * 设置MIP 本地服务IP(无网络时)
     *
     * @param ip IP
     */
    public static void setMipLocalIp(Context context, String ip) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_LOCAL_IP);
        info.setValue(ip);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * MIP本地服务IP(无网络时)
     *
     * @return IP
     */
    public static String getMipLocalIp(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_LOCAL_IP);
    }

    /**
     * 设置MIP本地服务端口(无网络时)
     *
     * @param port port
     */
    public static void setMipLocalPort(Context context, String port) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_LOCAL_PORT);
        info.setValue(port);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * MIP本地服务端口(无网络时)
     *
     * @return port
     */
    public static String getMipLocalPort(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_LOCAL_PORT);
    }

    /**
     * 设置MIP登录是否显示
     *
     * @param enable enable
     */
    public static void setMipLoginEnable(Context context, boolean enable) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(MIP_SETTING);
        info.setEditorMode(0);
        info.setKey(MIP_LOGIN_ENABLE);
        info.setValue(enable ? "1" : "0");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * MIP登录是否显示
     *
     * @return mip login enable
     */
    public static boolean getMipLoginEnable(Context context) {
        return ContentProviderUtil.getSharepreferenceBooleanValue(context, MIP_SETTING, MIP_LOGIN_ENABLE);
    }

    /**
     * 获取MIP自定义地址开关
     *
     * @return boolean true 自定义开，false自定义关
     */
    public static boolean getMipSwitch(Context context) {
        String value = ContentProviderUtil.getSharepreferenceValue(context, MIP_SETTING, MIP_CUSTOM_SWITCH);
        return TextUtils.equals("true", value);
    }

    /**
     * 设置存储天数
     *
     * @param context 上下文
     * @param days    天数
     */
    public static void setLogSaveDays(Context context, int days) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOG_SAVE_DAYS);
        info.setEditorMode(0);
        info.setKey(LOG_SAVE_DAYS);
        info.setValue(String.valueOf(days));
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取设置的日志存储天数，默认一天
     *
     * @param context
     * @return 天数（string类型）
     */
    public static String getLogSaveDays(Context context) {
        String days = ContentProviderUtil.getSharepreferenceValue(context, LOG_SAVE_DAYS, LOG_SAVE_DAYS);
        return days == null ? "1" : days;
    }

    /**
     * 保存SYS角色id
     *
     * @param context
     * @param sysRoleId
     */
    public static void setSysRoleId(Context context, String sysRoleId) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(SYS_ROLE_ID);
        info.setValue(null == sysRoleId ? "" : sysRoleId);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取SYS角色id
     *
     * @param context
     */
    public static String getSysRoleId(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, SYS_ROLE_ID);
    }

    /**
     * 保存SYS角色type
     *
     * @param context
     * @param sysRoleType
     */
    public static void setSysRoleType(Context context, String sysRoleType) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(SYS_ROLE_TYPE);
        info.setValue(null == sysRoleType ? "" : sysRoleType);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取SYS角色type
     *
     * @param context
     */
    public static String getSysRoleType(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, SYS_ROLE_TYPE);
    }


    /**
     * 拼接保存文本水印信息(供业务APP调用)
     */
    public static void setWaterMarkInfo(Context context) {
        StringBuilder builder = new StringBuilder();
        String userCode = SharepreferenceUtil.getUserCode(context);
        builder.append(userCode);
        builder.append(",");
        String orgCode = SharepreferenceUtil.getOrgCode(context);
        if (NetWorkUtil.getInstance().isConnected(context)) {
            String ipAddress = DeviceUtil.getIPAddress(context);
            String ip = "";
            String[] split = ipAddress.split("\\.");
            //采用ip后三节9位数字,单节不足3位在单节前补0
            for (int i = 1; i < split.length; i++) {
                String splitIp = split[i];
                if (splitIp.length() == 1) {
                    splitIp = "00" + splitIp;
                } else if (splitIp.length() == 2) {
                    splitIp = "0" + splitIp;
                }
                ip = ip + splitIp;
            }
            builder.append(orgCode);
            builder.append(",");
            builder.append(ip);
        }

        // 拼接保存水印内容
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(WATER_MARK_INFO);
        info.setValue(builder.toString());
        info.setType(0);

        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 清除水印文本信息(供业务APP调用)
     */
    public static void clearWaterMarkInfo(Context context) {
        // 拼接保存水印内容
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(WATER_MARK_INFO);
        info.setValue("");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取文本水印信息(逗号分割)
     *
     * @param context
     * @return userCode, deptCode, ip
     */
    public static String getWaterMarkInfo(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, WATER_MARK_INFO);
    }

    /**
     * 维护tokenList
     *
     * @param context
     * @param systemId
     * @param token
     */
    public static void saveSystemToken(Context context, String systemId, String token) {
        if (TextUtils.isEmpty(systemId) || TextUtils.isEmpty(token)) {
            return;
        }
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(BIND_CHECK_INFO);
        info.setEditorMode(0);
        info.setKey(systemId);
        info.setValue(token);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取系统token
     *
     * @param context
     * @param systemId
     */
    public static String getSystemToken(Context context, String systemId) {
        return ContentProviderUtil.getSharepreferenceValue(context, BIND_CHECK_INFO, systemId);
    }

    /**
     * 保存绑定的业务账号
     *
     * @param context
     * @param systemId
     * @param busiCode
     */
    public static void saveBindNumInfo(Context context, String systemId, String busiCode) {
        if (TextUtils.isEmpty(systemId) || TextUtils.isEmpty(busiCode)) {
            return;
        }
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(BIND_NUMBER_INFO);
        info.setEditorMode(0);
        info.setKey(systemId);
        info.setValue(busiCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取绑定的业务账号
     *
     * @param context
     * @param systemId
     */
    public static String getBindNumInfo(Context context, String systemId) {
        return ContentProviderUtil.getSharepreferenceValue(context, BIND_NUMBER_INFO, systemId);
    }

    /**
     * 保存上级机构编码
     */
    public static void setPerOrgCode(Context context, String perOrgCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(PER_ORG_CODE);
        info.setValue(perOrgCode);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取上级机构编码
     */
    public static String getPerOrgCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, PER_ORG_CODE);
    }

    /**
     * 保存供电单位类别
     */
    public static void setOrgType(Context context, String orgType) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(ORG_TYPE);
        info.setValue(orgType);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取供电单位类别
     */
    public static String getOrgType(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, ORG_TYPE);
    }

    /**
     * 保存调用者包名
     */
    public static void setCallerPackageName(Context context, String packageName) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(CALLER_PACKAGE_NAME);
        info.setValue(packageName != null ? packageName : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 读取调用者包名
     */
    public static String getCallerPackageName(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, CALLER_PACKAGE_NAME);
    }

    /**
     * 保存调用者账号
     */
    public static void setCallerUserCode(Context context, String userCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(CALLER_USER_CODE);
        info.setValue(userCode != null ? userCode : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 读取调用者账号
     */
    public static String getCallerUserCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, CALLER_USER_CODE);
    }

    /**
     * 保存调用者供电单位编码
     */
    public static void setCallerOrgNo(Context context, String orgNo) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(CALLER_ORG_NO);
        info.setValue(orgNo != null ? orgNo : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 读取调用者供电单位编码
     */
    public static String getCallerOrgNo(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, CALLER_ORG_NO);
    }

    /**
     * 保存调用者所属系统编码
     */
    public static void setCallerSysCode(Context context, String sysCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(CALLER_SYS_CODE);
        info.setValue(sysCode != null ? sysCode : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 读取调用者所属系统编码
     */
    public static String getCallerSysCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, CALLER_SYS_CODE);
    }

    /**
     * 保存调用者所要打开的app包名
     */
    public static void setBusinessPackageName(Context context, String businessPackageName) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(BUSINESS_PACKAGE_NAME);
        info.setValue(businessPackageName != null ? businessPackageName : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 读取调用者所要打开的app包名
     */
    public static String getBusinessPackageName(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, BUSINESS_PACKAGE_NAME);
    }

    /**
     * 保存调用者所要打开的app的启动类名
     */
    public static void setBusinessStartActivity(Context context, String businessStartActivity) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(BUSINESS_START_ACTIVITY);
        info.setValue(businessStartActivity != null ? businessStartActivity : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 读取调用者所要打开的app的启动类名
     */
    public static String getBusinessStartActivity(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, BUSINESS_START_ACTIVITY);
    }

    /**
     * 保存单点登录业务类型
     * 01：单点登录改造；02：计量异常采集异常融合
     */
    public static void setBusinessType(Context context, String setBusinessType) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(BUSINESS_TYPE);
        info.setValue(setBusinessType != null ? setBusinessType : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 读取单点登录业务类型
     */
    public static String getBusinessType(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, BUSINESS_TYPE);
    }

    /**
     * 获取so版本序号
     */
    public static String getSoVersion(Context context) {
        String soVersion = ContentProviderUtil.getSharepreferenceValue(context, SO_VERSION, SO_VERSION_CODE);
        if (TextUtils.isEmpty(soVersion)) {
            return "";
        }
        return soVersion;
    }

    /**
     * 存储安装版本名称
     * (这里为了上传上次安装版本号使用)
     */
    public static void saveInstallVersionName(Context context, String packageName, String versionName) {
        if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(versionName)) {
            return;
        }
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(BEFORE_VERSION_NAME);
        info.setEditorMode(0);
        info.setKey(packageName);
        info.setValue(versionName);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取版本名称
     * (这里为了上传上次安装版本号使用)
     */
    public static String getBeforeVersionName(Context context, String packageName) {
        String beforeVersionName = ContentProviderUtil.getSharepreferenceValue(context, BEFORE_VERSION_NAME, packageName);
        if (TextUtils.isEmpty(beforeVersionName)) {
            return "";
        }
        return beforeVersionName;
    }

    /**
     * 保存系统通用参数数据
     */
    public static void saveCommParamData(Context context, String data) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(COMM_PARAM_DATA);
        info.setValue(data);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取系统通用参数保存
     */
    public static String getCommParamData(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, COMM_PARAM_DATA);
    }

    /**
     * 是否显示水印信息
     * APP_WHETHER_WATERMARK 0不显示 1显示
     */
    public static void saveWaterMark(Context context, String waterMarkKey, String waterMark) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(waterMarkKey);
        info.setValue(waterMark);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取是否显示水印信息
     */
    public static String getWaterMark(Context context, String waterMarkKey) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, waterMarkKey);
    }

    /**
     * 设置登录方式
     * (是否人脸识别登陆)
     * "0"账号登陆
     * "1"人脸登陆
     *
     * @param context
     * @param loginMothed
     */
    public static void saveLoginMothed(Context context, String loginMothed) {
        SharepreferenceInfo sharepreferenceInfo = new SharepreferenceInfo();
        sharepreferenceInfo.setKey(LOGIN_MODE);
        sharepreferenceInfo.setValue(loginMothed);
        sharepreferenceInfo.setEditorKey(IS_FACE_LOGIN);
        sharepreferenceInfo.setEditorMode(0);
        sharepreferenceInfo.setType(0);
        ContentProviderUtil.setSharepreference(context, sharepreferenceInfo);
    }

    /**
     * 获取登陆方式
     * (是否人脸识别登陆)
     */
    public static String getLoginMothed(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, IS_FACE_LOGIN, LOGIN_MODE);
    }

    /**
     * 设置电表通讯方式
     *
     * @param context
     * @param meterCommMode "0" = "默认"
     *                      "1" = "485串口"
     *                      "2" = "红外"
     *                      "3" = "激光红外"
     */
    public static void setMeterCommMode(Context context, String meterCommMode) {
        SharepreferenceInfo sharepreferenceInfo = new SharepreferenceInfo();
        sharepreferenceInfo.setKey(METER_COMM_MODE);
        sharepreferenceInfo.setValue(meterCommMode);
        sharepreferenceInfo.setEditorKey(METER_COMM_SETTING);
        sharepreferenceInfo.setEditorMode(Context.MODE_PRIVATE);
        sharepreferenceInfo.setType(0);
        ContentProviderUtil.setSharepreference(context, sharepreferenceInfo);
    }

    /**
     * 获取保存的电表通讯方式
     *
     * @param context
     * @return "0" = "默认"
     * "1" = "485串口"
     * "2" = "红外"
     * "3" = "激光红外"
     */
    public static String getMeterCommMode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, METER_COMM_SETTING, METER_COMM_MODE);
    }

    /**
     * 设置电表通讯方式-485串口波特率
     *
     * @param context
     * @param baud    波特率范围为1200、2400、4800、9600、14400、19200、38400
     */
    public static void setMeter485Baud(Context context, String baud) {
        SharepreferenceInfo sharepreferenceInfo = new SharepreferenceInfo();
        sharepreferenceInfo.setKey(METER_485_BAUD);
        sharepreferenceInfo.setValue(baud);
        sharepreferenceInfo.setEditorKey(METER_COMM_SETTING);
        sharepreferenceInfo.setEditorMode(Context.MODE_PRIVATE);
        sharepreferenceInfo.setType(0);
        ContentProviderUtil.setSharepreference(context, sharepreferenceInfo);
    }

    /**
     * 获取电表通讯方式-485串口波特率
     *
     * @param context
     * @return 波特率范围为1200、2400、4800、9600、14400、19200、38400
     */
    public static String getMeter485Baud(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, METER_COMM_SETTING, METER_485_BAUD);
    }

    /**
     * 设置电表通讯方式-485串口数据位
     *
     * @param context
     * @param bit     数据位范围：5、6、7、8
     */
    public static void setMeter485DataBit(Context context, String bit) {
        SharepreferenceInfo sharepreferenceInfo = new SharepreferenceInfo();
        sharepreferenceInfo.setKey(METER_485_DATA_BIT);
        sharepreferenceInfo.setValue(bit);
        sharepreferenceInfo.setEditorKey(METER_COMM_SETTING);
        sharepreferenceInfo.setEditorMode(Context.MODE_PRIVATE);
        sharepreferenceInfo.setType(0);
        ContentProviderUtil.setSharepreference(context, sharepreferenceInfo);
    }

    /**
     * 获取电表通讯方式-485串口数据位
     *
     * @param context
     * @return 数据位范围：5、6、7、8
     */
    public static String getMeter485DataBit(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, METER_COMM_SETTING, METER_485_DATA_BIT);
    }

    /**
     * 设置电表通讯方式-485串口校验位
     *
     * @param context
     * @param bit     校验位范围：无(0)、奇(1)、偶(2)
     */
    public static void setMeter485CheckBit(Context context, String bit) {
        SharepreferenceInfo sharepreferenceInfo = new SharepreferenceInfo();
        sharepreferenceInfo.setKey(METER_485_CHECK_BIT);
        sharepreferenceInfo.setValue(bit);
        sharepreferenceInfo.setEditorKey(METER_COMM_SETTING);
        sharepreferenceInfo.setEditorMode(Context.MODE_PRIVATE);
        sharepreferenceInfo.setType(0);
        ContentProviderUtil.setSharepreference(context, sharepreferenceInfo);
    }

    /**
     * 获取电表通讯方式-485串口校验位
     *
     * @param context
     * @return 校验位范围：无(0)、奇(1)、偶(2)
     */
    public static String getMeter485CheckBit(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, METER_COMM_SETTING, METER_485_CHECK_BIT);
    }

    /**
     * 设置电表通讯方式-485串口停止位
     *
     * @param context
     * @param bit     停止位范围：0、1、1.5、2
     */
    public static void setMeter485StopBit(Context context, String bit) {
        SharepreferenceInfo sharepreferenceInfo = new SharepreferenceInfo();
        sharepreferenceInfo.setKey(METER_485_STOP_BIT);
        sharepreferenceInfo.setValue(bit);
        sharepreferenceInfo.setEditorKey(METER_COMM_SETTING);
        sharepreferenceInfo.setEditorMode(Context.MODE_PRIVATE);
        sharepreferenceInfo.setType(0);
        ContentProviderUtil.setSharepreference(context, sharepreferenceInfo);
    }

    /**
     * 获取电表通讯方式-485串口停止位
     *
     * @param context
     * @return 停止位范围：0、1、1.5、2
     */
    public static String getMeter485StopBit(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, METER_COMM_SETTING, METER_485_STOP_BIT);
    }

    /**
     * 设置是否进行MDS账号绑定校验
     * BINDING_CHECK_USER 0不进行 1进行
     */
    public static void setIsBindingCheckUser(Context context, String isBindingCheckUserValue) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(IS_BINDING_CHECK_KEY);
        info.setValue(isBindingCheckUserValue);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取是否进行MDS账号绑定校验
     * BINDING_CHECK_USER 0不进行 1进行
     */
    public static String getIsBindingCheckUser(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, IS_BINDING_CHECK_KEY);
    }

    public static void setOneKeyPackageState(Context context, String oneKeyPackageState) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(ONE_KEY_PACKAGE_STATE);
        info.setValue(oneKeyPackageState);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    public static String getOneKeyPackageState(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, ONE_KEY_PACKAGE_STATE);
    }

    /**
     * 是否开启一键执行功能
     *
     * @param context
     * @return true为开启，false 为关闭。默认关闭
     */
    public static boolean isOneKeyPackageOpen(Context context) {
        String oneKeyPackageState = getOneKeyPackageState(context);
        return "1".equalsIgnoreCase(oneKeyPackageState) ? true : false;
    }

    /**
     * 设置工单自动上传时间；单位s
     */
    public static void setOrderUploadTime(Context context, String time) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(ORDER_UPLOAD_TIME);
        info.setValue(!TextUtils.isEmpty(time) ? time : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取工单自动上传时间；单位s
     */
    public static String getOrderUploadTime(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, ORDER_UPLOAD_TIME);
    }

    /**
     * 设置应用分块下载大小；单位kb
     */
    public static void setAppDownloadSize(Context context, String downloadSize) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(APP_DOWNLOAD_SIZE);
        info.setValue(!TextUtils.isEmpty(downloadSize) ? downloadSize : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取应用分块下载大小；单位kb
     */
    public static String getAppDownloadSize(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, APP_DOWNLOAD_SIZE);
    }

    /**
     * 设置文件分块上传大小；单位kb
     */
    public static void setFileUploadSize(Context context, String uploadSize) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(FLIE_UPLOAD_SIZE);
        info.setValue(!TextUtils.isEmpty(uploadSize) ? uploadSize : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取文件分块上传大小；单位kb
     */
    public static String getFileUploadSize(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, FLIE_UPLOAD_SIZE);
    }

    /**
     * 设置允许文件上传类型
     */
    public static void setWFFileUploadType(Context context, String uploadtype) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(WF_FILE_UPLOAD_TYPE);
        info.setValue(!TextUtils.isEmpty(uploadtype) ? uploadtype : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取允许文件上传类型
     */
    public static String getWFFileUploadType(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, WF_FILE_UPLOAD_TYPE);
    }

    /**
     * 设置允许文件上传大小；单位kb
     */
    public static void setWFFileUploadSize(Context context, String uploadSize) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(WF_FILE_UPLOAD_SIZE);
        info.setValue(!TextUtils.isEmpty(uploadSize) ? uploadSize : "");
        info.setType(0);
//        ContentProviderUtil.setSharepreference(context, info);
        //TODO getModel().insertInfo(info);
    }

    /**
     * 获取允许文件上传大小；单位kb
     */
    public static String getWFFileUploadSize(Context context) {
//        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, WF_FILE_UPLOAD_SIZE);
        //TODO return getModel().queryString(COMM_PARAM,WF_FILE_UPLOAD_SIZE);
        return "";
    }

    /**
     * 保存APP参数更新版本号
     */
    public static void setAppParamUpdateVersion(Context context, String version) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(APP_PARAM_UPDATE_VERSION);
        info.setValue(!TextUtils.isEmpty(version) ? version : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取APP参数更新版本号
     */
    public static String getAppParamUpdateVersion(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, APP_PARAM_UPDATE_VERSION);
    }

    /**
     * 保存首页Banner图
     */
    public static void setBannerImg(Context context, String bannerImg) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(BANNER_IMG);
        info.setValue(!TextUtils.isEmpty(bannerImg) ? bannerImg : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取首页Banner图
     */
    public static String getBannerImg(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, BANNER_IMG);
    }

    /**
     * 保存APP版本号
     */
    public static void saveAppVersionCode(Context context, int versionCode) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(APP_VERSION_CODE);
        info.setValue(String.valueOf(versionCode));
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取APP参数更新版本号
     */
    public static String getAppVersionCode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, APP_VERSION_CODE);
    }
	
	/**
     * 设置初始密码
     */
    public static void setOrigionPwd(Context context, String origionPwd) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(ORIGION_KEY);
        info.setValue(!TextUtils.isEmpty(origionPwd) ? origionPwd : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取初始密码
     */
    public static String getOrigionPwd(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, ORIGION_KEY);
    }

    /**
     * 存储密码规则
     */
    public static void setPwdRegex(Context context, String pwdRegex) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(COMM_PARAM);
        info.setEditorMode(0);
        info.setKey(KEY_REGEX);
        info.setValue(!TextUtils.isEmpty(pwdRegex) ? pwdRegex : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取密码规则
     */
    public static String getPwdRegex(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, COMM_PARAM, KEY_REGEX);
    }

    /**
     * 保存用户人员职责信息
     */
    public static void setOperDuty(Context context, String operDuty) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(LOGININFO);
        info.setEditorMode(0);
        info.setKey(OPER_DUTY);
        info.setValue(operDuty != null ? operDuty : "");
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取用户人员职责信息
     */
    public static String getOperDuty(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, LOGININFO, OPER_DUTY);
    }

    /**
     * 设置是否加密
     * @param context
     * @param isEncrypted 加密1 不加密0
     */
    public static void setEncryptMode(Context context, String isEncrypted) {
        SharepreferenceInfo info = new SharepreferenceInfo();
        info.setEditorKey(ENCRYPTIONMODE);
        info.setEditorMode(0);
        info.setKey(ENCRYPTION_MODE);
        info.setValue(isEncrypted);
        info.setType(0);
        ContentProviderUtil.setSharepreference(context, info);
    }

    /**
     * 获取uid
     *
     * @param context
     * @return
     */
    public static String getEncryptionMode(Context context) {
        return ContentProviderUtil.getSharepreferenceValue(context, ENCRYPTIONMODE, ENCRYPTION_MODE);
    }

}
